package com.example.Server;

import com.example.Mapper.Topic_Mapper;
import com.example.Model.QutionModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AdminServer {

    @Autowired
    public Topic_Mapper mapper;
    //添加一道题
    @Transactional
    public int CommitQution(QutionModel model){
          int id= mapper.AddCodeTempter(model.tempter);
             System.out.println(id);
          int cid=Integer.parseInt((model.tempter.get("id")));
          System.out.println("cid"+cid);
          mapper.AddCodeHead(model.head);
          int jid=Integer.parseInt((model.head.get("id")));
          System.out.println("jid"+jid);
          mapper.addQution(model.qution,jid);
          int qid=Integer.parseInt((model.qution.get("id")));
          if (mapper.addTopic(qid,cid)<0){
            return 0;
          }
          return -1;
    }

}
